package com.itao.springboot.controller;

import com.itao.springboot.bean.CallbackDto;
import com.itao.springboot.bean.GetOrderDto;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author sjt
 * @CreateTime 2025/9/26 8:54
 */
@Slf4j
@RestController
@RequestMapping("/api/order")
public class ThirdOthersController {

    @PostMapping("/getOrder")
    public Map<String, Object> getOrder(@RequestBody @Valid GetOrderDto dto) {
        log.info("参数：{}",  dto);
        Map<String, Object> res = new HashMap<>();
        res.put("return_code", "SUCCESS");
        res.put("return_msg", null);

        Map<String, Object> order = new HashMap<>();
        res.put("order", order);
        order.put("order_no", dto.getOrder_no());
        order.put("product", "美式咖啡");
        order.put("price", 1000);
        order.put("img", "https://copyright.bdstatic.com/vcg/creative/15033b7ddfc23f9b133d4087b6da460a.jpg");
        order.put("is_cold", 0);
        return res;
    }

    @PostMapping("/callback")
    public Map<String, Object> callback(@RequestBody @Valid CallbackDto dto) {
        log.info("参数：{}",  dto);
        Map<String, Object> res = new HashMap<>();
        res.put("return_code", "FAIL");
        res.put("return_msg", "网络异常");
        return res;
    }
}
